<template>
    <div class="bg">
        <Header :nowDate="nowDate" />
        <Left/>
        <Middle/>
        <Right/>

    </div>
</template>

<script>
const zhzxIcon = require("../../assets/dp1/zhzx.png");
const djztIcon = require("../../assets/dp1/djzt.png");
const zwztIcon = require("../../assets/dp1/zwzt.png");
const zzztIcon = require("../../assets/dp1/zzzt.png");
const cgztIcon = require("../../assets/dp1/cgzt.png");

import Ws from "../../utils/ws";

import Header from "../../components/dp3/header";
import Left from "../../components/dp3/left";
import Right from "../../components/dp3/right";
import Middle from "../../components/dp3/middle";
import { getNowDate, delay } from "../../utils";
import { getWeather } from "../../config/api";
export default {
    components: {
        Header,
        Left,
        Right,
        Middle
    },
    data() {
        return {
            currentIndex: 2, //大屏专栏操作列表下标
            nowDate: {
                date: "",
                hours: "",
                minutes: "",
                seconds: "",
                weekDay: ""
            },
            dpList: [
                { name: "综合展现", icon: zhzxIcon, type: 1, path: "/dp1" },
                { name: "党建专题", icon: djztIcon, type: 2, path: "/dp2" },
                { name: "政务专题", icon: zwztIcon, type: 3, path: "/dp3" },
                { name: "综治专题", icon: zzztIcon, type: 4 },
                { name: "城管专题", icon: cgztIcon, type: 5 },
                { name: "", icon: "+", type: 6 }
            ]
        };
    },
    mounted() {
        let w = new Ws();
        // w.initWebSocket();
        this.nowTimes();
        this.getWeather();
        this.timer = delay.setInterval(this.nowTimes, 1000);
        this.timer1 = setInterval(this.getWeather, 1000 * 60 * 30);
    },
    destroyed() {
        this.timer && delay.clearInterval(this.timer);
        this.timer1 && clearInterval(this.timer1);
    },
    methods: {
        handleDpType(item, index) {
            this.currentIndex = index;
            if (item.path) {
                this.$router.push(item.path);
            }
        },
        /**
         * 获取天气
         */
        getWeather() {
            getWeather().then((result = {}) => {
                this.weatherInfo = result.data || {};
            });
        },
        /**
         * 实时获取年月日时分秒定时器
         */
        nowTimes() {
            this.nowDate = getNowDate();
        }
    }
};
</script>

<style lang="scss" scoped>
.bg {
    height: 896px;
    width: 3072px;
    background: url("../../assets/dp3/dp3-bg.png") no-repeat;
    background-size: 100% 100%;
    position: relative;
    display: flex;
    color: #fff;
}
</style>